<template>
  <div class="font-button" @click="sumbit()">ok</div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "ComBtn",
  props: {},
  computed: {
    ...mapState("handlegame", ["gameInfo"])
  },
  data() {
    return {};
  },
  methods: {
    sumbit() {
      this.$store.dispatch("handlegame/submit").then(
        res => {
          if (res.data.code === "200") {
            this.$toast(this.$t("xzcg"));
            this.$store.commit("handlegame/INITDATA");
            this.$store.commit("handlegame/INTE_PAGE_STATE", true);
            this.$store.dispatch("user/getMineInfo");
            this.$store.dispatch("websock/getHisToryList");
            this.$store.dispatch("websock/GETbethistorylist");
          } else {
            this.$toast({
              message: this.$t("xzsb") + res.data.message,
              duration: 2000
            });
          }
        },
        error => {
          // 这里的 error 就是在 reject(emptyFields) 处的错误信息
          var errorData = error;
          for (var i = 0; i <= errorData.length; i++) {
            if (errorData[i] === "betParam") {
              this.$toast({
                message: this.$t("qxztzdx"),
                duration: 2000
              });
              return;
            }
            if (errorData[i] === "credit") {
              this.$toast({
                message: this.$t("qxztzje"),
                duration: 2000
              });
              return;
            }
            if (errorData[i] === "ruleId") {
              this.$toast({
                message: this.$t("qxzyxxm"),
                duration: 2000
              });
              return;
            }
          }
        }
      );
    }
  }
};
</script>
<style lang="less" scoped>
.font-button {
  width: 136px;
  height: 34px;
  background-image: url(@/assets/images/payOrder/border.png);
  background-size: 136px 34px;
  background-repeat: no-repeat;
  font-size: 16px;
  text-align: center;
  line-height: 34px;
  font-weight: bold;
  color: #ffd486;
  cursor: pointer;
}
</style>
